            
class RoomController {
    def index = { redirect(action:list,params:params) }

    // the delete, save and update actions only
    // accept POST requests
    def allowedMethods = [delete:'POST',
                          save:'POST',
                          update:'POST']

    def list = {
        if(!params.max)params.max = 10
        [ roomList: Room.list( params ) ]
    }

    def show = {
        [ room : Room.get( params.id ) ]
    }

    def delete = {
        def room = Room.get( params.id )
        if(room) {
            room.delete()
            flash.message = "Room ${params.id} deleted."
            redirect(action:list)
        }
        else {
            flash.message = "Room not found with id ${params.id}"
            redirect(action:list)
        }
    }

    def edit = {
        def room = Room.get( params.id )

        if(!room) {
                flash.message = "Room not found with id ${params.id}"
                redirect(action:list)
        }
        else {
            return [ room : room ]
        }
    }

    def update = {
        def room = Room.get( params.id )
        if(room) {
             room.properties = params
            if(room.save()) {
                redirect(action:show,id:room.id)
            }
            else {
                render(view:'edit',model:[room:room])
            }
        }
        else {
            flash.message = "Room not found with id ${params.id}"
            redirect(action:edit,id:params.id)
        }
    }

    def create = {
        def room = new Room()
        room.properties = params
        return ['room':room]
    }

    def save = {
        def room = new Room()
        room.properties = params
        if(room.save()) {
            redirect(action:show,id:room.id)
        }
        else {
            render(view:'create',model:[room:room])
        }
    }

}